//index.js

var app = getApp();
var ImageURL = app.globalData1.ImageURL;
var hostURL = app.globalData1.hostURL;


console.log(ImageURL)
Page({
  data: {
    indexSortList: [],

    curNav: 1,
    curIndex: 0,
    ImageURL: ImageURL,
    banner: [
      {
        "id": 1,
        "imgSrc": "/static/images/swiper1.jpg"
      },
      {
        "id": 2,
        "imgSrc": "/static/images/swiper2.jpg"
      },
      {
        "id": 3,
        "imgSrc": "/static/images/swiper3.jpg"
      }
    ],

    channel: [
      { "url": "pages/catalog/catalog", "icon_url": "https://i04picsos.sogoucdn.com/04eb8d83489c0402" }
    ],
    topics: []
  },


  onLoad: function () {

    var that = this

    

    wx.request({
      url: hostURL + 'sharedplatform-web/source/list.action',
      method: 'GET',
      data: {},
      header: {
        'Accept': 'application/json'
      },
      success: function (res) {
        console.log("请求成功")
        that.setData({
          indexSortList: res.data.indexSortList,

        })
      }
    })

  },

  //事件处理函数  
  switchTab: function (e) {
    // 获取item项的id，和数组的下标值  
    let id = e.target.dataset.id,
      index = parseInt(e.target.dataset.index);
    // 把点击到的某一项，设为当前index  
    this.setData({
      curNav: id,
      curIndex: index
    })

  },
  togoods: function (e) {
    var sourceId = e.currentTarget.dataset.id
    console.log(sourceId)
    wx.navigateTo({
      url: "/pages/goods/goods?sourceId=" + e.currentTarget.dataset.id,
    })

  },
  swipclick: function (e) {//点击图片触发事件
   wx.navigateTo({
     url: '../info/info',
   })
  },

})